package io.gitee.zhangbinhub.admin.oauth.controller.openinner

import io.gitee.zhangbinhub.acp.boot.exceptions.WebException
import io.gitee.zhangbinhub.admin.common.api.CommonPath
import io.gitee.zhangbinhub.admin.common.api.OauthApi
import io.gitee.zhangbinhub.admin.common.base.BaseController
import io.gitee.zhangbinhub.admin.oauth.service.RoleService
import io.gitee.zhangbinhub.admin.resource.server.vo.RoleVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.noear.solon.annotation.Controller
import org.noear.solon.annotation.Mapping
import org.noear.solon.annotation.Path
import org.noear.solon.core.handle.MethodType
import org.noear.solon.core.util.MimeType
import org.noear.solon.validation.annotation.Valid

@Valid
@Controller
@Api("角色信息（内部开放接口）")
open class OpenInnerRoleController(private val roleService: RoleService) : BaseController() {
    @ApiOperation("获取角色详细信息")
    @Mapping(
        method = [MethodType.GET],
        value = CommonPath.openInnerBasePath + OauthApi.roleConfig + "/{roleId}",
        produces = MimeType.APPLICATION_JSON_VALUE
    )
    @Throws(WebException::class)
    fun roleInfo(@Path(name = "roleId") roleId: String): RoleVo = roleService.getRoleInfo(roleId)

    @ApiOperation("获取角色列表")
    @Mapping(
        method = [MethodType.GET],
        value = CommonPath.openInnerBasePath + OauthApi.roleConfig,
        produces = MimeType.APPLICATION_JSON_VALUE
    )
    @Throws(WebException::class)
    fun roleList(): List<RoleVo> = roleService.getRoleVoList()
}